Joystick Information

The game or joystick port is the only analogue input for the PC, it can be used to read up to 4 potentiometer inputs, using the rate of decay across a capacitance in combination with the potentiometer resistance to measure the game paddle setting. The capacitance is charged up, a flag is set to one (bit 0 of Port 201H), a timer is started, and the capacitance discharges across the resistance of the game potentiometer. When it reaches a preset value (arbitrarily shown in the diagram as 5 half lives), the flag is set to 0 and the timer stops. The time is then a measure of the resistance (position) of the game paddle. The other bits in the port address 201H are all normally set to 1. Hence the decay is marked by a change in the flag bit from a 1 to a 0, and the Port 201H reads 255 (11111111)during the decay, 254 (11111110) at the end.

Game Paddle Operation

Sam worked out a QBASIC routine which seems to work :

   REM Sam's program to measure the game paddle using the
   REM the OUT function from QBASIC
   CLS
   PRINT , "Starting"
   FOR a = 1 TO 2000
     OUT &H201, 255 'set the game port flag to one
     p = 0
     WHILE NOT (INP(&H201) = 254)
       p = p + 1
     WEND
     PRINT, p
     FOR r = 0 TO 20000
     NEXT r
   NEXT a
   END
The above code shows how to write a programme which is independent of the STICK(0) function. It does not give a realistic value for the resistance though since the BASIC counting loop is too slow.

Version 1.1 9th May 1998